package bdhub.littletail.app.process.main;

import android.app.ActivityManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;

import java.util.List;

import bdhub.littletail.app.message.AppMessage;
import bdhub.littletail.lib.utils.log.CLog;

/**
 * Created by BDHub-7 on 2016/2/24.
 * chenshichao@outlook.com
 */
public class MainService extends Service {

    private static final String TAG = MainService.class.getSimpleName();

    @Override
    public void onCreate() {
        CLog.v(TAG, "onCreate()");
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        CLog.v(TAG, "onStartCommand()");
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        CLog.v(TAG, "onDestroy()");
    }

    @Override
    public boolean onUnbind(Intent intent) {
        CLog.v(TAG, "onUnbind()");
        return super.onUnbind(intent);
    }

    @Override
    public void onRebind(Intent intent) {
        CLog.v(TAG, "onRebind()");
    }

    @Override
    public IBinder onBind(Intent intent) {
        CLog.v(TAG, "onBind()");
        return mBinder;
    }

    private final IMainReceiver.Stub mBinder = new IMainReceiver.Stub() {
        @Override
        public int onReceiverMessage(AppMessage msg) throws RemoteException {
            CLog.d(TAG, "Current Process is " + android.os.Process.myPid());
            fetchProcessInfo();
            CLog.d(TAG, "MainService...onReceiverMessage()");
            return 0;
        }

        @Override
        public int updateState(int status) throws RemoteException {
            CLog.d(TAG, "MainService...updateState()");
            return 0;
        }

        @Override
        public void stopService() throws RemoteException {
            CLog.d(TAG, "MainService...stopService()");
        }
    };

    private void fetchProcessInfo() {

    }
}
